Release 10.1A: OpenEdge Data Management:
SQL Reference
UPDATE STATISTICS
Queries data tables and updates the following statistics:
Syntax
Examples
The following example shows default commands for table cardinality and data distribution for index component columns:
The following example shows commands for table cardinality only:
The following example shows commands for new index statistics:
The following example shows commands for updating column statistics for index columns only:
The following example shows commands for updating statistics for all columns:
The following example shows commands to obtain table cardinality and new index statistics and column statistics for all columns:
Notes
- All statistics are obtained online. Obtaining statistics does not require an exclusive lock on the schema or any table locks. Rows written to statistics tables will be exclusively locked, as in every transaction performing updates. Therefore, statistics can be obtained while normal database operations continue.
- Specifying
TABLE STATISTICSobtains table cardinality only. Table cardinalities are stored in theSYSTABLSTATsystem catalog table.- Specifying
INDEX STATISTICSobtains statistics on the number of unique values in each index. Index statistics are stored in theSYSIDXSTATsystem catalog table.- Specifying
COLUMN STATISTICS(withoutALL) obtains statistics on the data distribution of values for each column that is an index key component.- Specifying
ALL COLUMN STATISTICSobtains statistics on the data distribution of values for all columns.- The
STATISTICSphrase can be repeated so that up to three statistics can be requested by a singleUPDATE STATISTICSstatement.- By default, for the simple statement
UPDATE STATISTICS, where the type of statistics is not specified, SQL will obtain table and index column statistics. This is equivalent to the statementUPDATE TABLE STATISTICS AND COLUMN STATISTICS.- A table containing
LONGdata types can get table, index, and/or column statistics. The columns that areLONGdata types cannot get statistics.- Obtaining table statistics runs in time proportional to the table’s primary index.
- Obtaining column statistics runs in time proportional to the table’s primary index, plus an additional amount proportional to the number of columns in the table.
- Obtaining index statistics runs in time proportional to the total size for all indexes for the table.
- Table statistics are often the most useful statistic, as they influence join order substantially.
- Index statistics are important when a table has five or more indexes. This is especially true if some of the indexes are similar to one another.
- Column statistics are the most useful when applications use range predicates, such as
BETWEENand the operators <, <=, > and >=.Authorization
Must have
DBAprivilege,SELECTprivilege, or ownership of table.Related statements
None
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |